package com.qipay.api.redirect.controller.v1;

import com.qipay.baas.model.Order;
import com.qipay.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/redirect/v1/yl")
/**
 * 银联快捷
 */
public class YLNetRedirectController {

    @Autowired
    OrderService orderService;

    @RequestMapping(value = "/net", method = RequestMethod.GET,produces = {"application/xml;charset=UTF-8"})
    private ModelAndView pay(
            HttpServletRequest request,
            @RequestParam("merchantOrderId") String merchantOrderId,
            HttpServletResponse response
    ) throws Exception {
        Order order = orderService.getByTradeNo(merchantOrderId);
        ModelAndView view = null;
        if(order!=null&&order.getState()!=3){
            String result = order.getRemark();
            view = new ModelAndView("/pay/online_bank");
            view.addObject("result",result);
        }
        return view;
    }

}
